# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.50.1"

default_platform :ios

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    
    
  end

desc "ManagerLib 这个航道，可以快速对自己的私有库进行升级维护"
lane :ManagerLib do |options|
    tagName = options[:tag]
    specName = options[:spec]

    # 1.pod install
    cocoapods(
        clean: true,
        podfile: "./Example/Podfile"
    )

    # 2. git add .
    git_add(path: ".")

    # 2.1 git commit -m ''
    git_commit(path: ".", message: "私有库 #{tagName} 升级维护")

    # 2.2 git push origin master
    push_to_git_remote

    # 3. git tag 标签名称
    add_git_tag(
        tag: tagName
    )
    # 3.1 git push --tags
    push_git_tags

    # 4. pod spec lint 验证podSpec
    pod_lib_lint(allow_warnings: true)

    # 4.1 pod repo push XXX  xxx.podspec
    pod_push(path: "#{specName}.podspec", repo: "ZQQFMSpecs", allow_warnings: true)
end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    # match(type: "appstore") # more information: https://codesigning.guide
    gym # Build your app - more options available
    pilot

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used. No personal data is recorded. 
# Learn more at https://github.com/fastlane/fastlane#metrics
